<?php
header("content-type:text/html;charset:utf-8");

// 传入客户端的参数
$v = $_GET["value"];
$link = mysqli_connect("localhost","root","","user");

mysqli_set_charset($link,"utf8");

$sql = "select * from onlygoods where goods_name like '%$v%'";

$result = mysqli_query($link,$sql);
// 创建空数组
$ar1 = [];
// 遍历结果集中每条数据
while($row= mysqli_fetch_assoc($result)){
    array_push($ar1,$row);
}
// 给数组编码并输出
echo json_encode($ar1);
// 关闭数据库
mysqli_close($link);

?>